<template>
    <el-dialog :visible.sync="show" title="修改信息" width="30%">
        <div class="hidden-sm-and-down">
            <el-form ref="elForm" :model="Value" :rules="rules" label-width="100px" size="medium">
---
                <el-form-item  label="@{field.label}"  prop="@{field.name}"> @{field}
                    <el-input v-model="Value[@{field.name}]" style="width: 100%"
                              clearable :placeholder="'请输入'+value">
                    </el-input>
                </el-form-item>
+++
                <el-form-item size="large">
                    <el-button type="primary" @click="submitForm">提交</el-button>
                    <el-button @click="resetForm">重置</el-button>
                    <el-button type="primary" @click="#{database}UpdateClose">取消</el-button>
                    <br>
                    <span style="color: #00ffff;">{{ message }}</span>
                </el-form-item>
            </el-form>
        </div>
    </el-dialog>

</template>
<script>
import {update#{Database}} from "@/api/#{database}Server";

export default {
    name: '#{database}Update',
    components: {},
    data() {
        return {
            show: false,
            Value:{
                "@{field.name}":null,@{field}
            },
            msg:{
                "@{field.name}":null,@{field}
            },
            message: '',
            id: 0,
            rules: {},
        }
    },
    computed: {},
    mounted() {
        this.$bus.$on('#{database}UpdateOpen', this.#{database}UpdateOpen)      // 显示更新会话
        this.$bus.$on('#{database}UpdateClose', this.#{database}UpdateClose)    // 关闭更新会话
    },
    beforeCreate() {
        this.$bus.$off('#{database}UpdateOpen')
        this.$bus.$off('#{database}UpdateClose')
    },
    methods: {
        #{database}UpdateOpen(msg) {
            this.msg = msg
            this.resetForm()
            this.show = true
        },
        #{database}UpdateClose() {
            this.show = false
        },
        // 提交表单
        submitForm() {
            update#{Database}().then(response => {
            // 更新成功，提交表格
                this.$bus.$emit('#{database}UpDataTable', this.Value)
            })
        },
        // 重置表单
        resetForm() {
            this.Value.@{field.name} = this.msg["@{field.name}"]@{field}
        },
    }
}
</script>
<style>
.el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
}
</style>
